Intersection of array&hasOffset is accepted by non-empty-array#4766
Merged
ondrejmirtes merged 7 commits intophpstan:2.1.xfrom Jan 19, 2026
Merged
Intersection of array&hasOffset is accepted by non-empty-array#4766ondrejmirtes merged 7 commits intophpstan:2.1.xfrom
ondrejmirtes merged 7 commits intophpstan:2.1.xfrom
Conversation
Contributor
Author
|
|
Contributor
Author
|
ok, I think its fine. |
455abe8 to
f6bb448
Compare
Collaborator
|
This pull request has been marked as ready for review. |
This was referenced Jan 16, 2026
f6bb448 to
6ca1e8c
Compare
ondrejmirtes
requested changes
Jan 18, 2026
| public function accepts(Type $type, bool $strictTypes): AcceptsResult | ||
| { | ||
| if ($type instanceof CompoundType) { | ||
| return $type->isAcceptedBy($this, $strictTypes); |
Member
There was a problem hiding this comment.
I don't understand this. All Accessory types do this. So it has to stay.
But you can do another condition before this one, like AccessoryNonEmptyStringType does:
public function accepts(Type $type, bool $strictTypes): AcceptsResult
{
if ($type->isNonEmptyString()->yes()) {
return AcceptsResult::createYes();
}
if ($type instanceof CompoundType) {
return $type->isAcceptedBy($this, $strictTypes);
}
return new AcceptsResult($type->isNonEmptyString(), []);
}You can also try doing the same thing (call related method before instanceof CompoundType) in other Accessory types so they all still look the same..
Contributor
Author
There was a problem hiding this comment.
I will look into other accessories in a separate PR
done
6ca1e8c to
f5d6e26
Compare
Member
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes phpstan/phpstan#13964